package com.bee.shepherd.rpc.qmq.producer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import qunar.tc.qmq.Message;
import qunar.tc.qmq.MessageProducer;
import qunar.tc.qmq.ReliabilityLevel;

import javax.annotation.Resource;

/**
* Created by xiaolong.zhao on 19/1/24.
*/
@Service
public class DemoProducer {

    private static final Logger logger = LoggerFactory.getLogger(DemoProducer.class);

    @Value("${qmq.demo.topic}")
    private String subject;

//    @Resource
    private MessageProducer messageProducer;

    public void sendMessage(String content) {

        Message message = messageProducer.generateMessage(subject);
        message.setReliabilityLevel(ReliabilityLevel.High);

        //todo 业务代码
        message.setProperty("content", content);
        messageProducer.sendMessage(message);
    }
}
